Compiler options for mips

Contents|Index|Previous|Next
Compiler options for MIPS

When you run GCC, you can use command-line options to choose machine-specific details. For information on all the GCC command-line options, see GNU CC command options in Using GNU CC in GNUPro Compiler Tools. There are a great many compiler options for specific MIPS targets. The following documentation discusses some of them. For instance, options for architecture and code generation (described in GCC options for architecture and code generation for MIPS) are for all MIPS targets. See also `gcc` options for floating point for MIPS and Floating point subroutines.

Note:
The compiler options, -mips2, -mips3 and -mips4, cannot be used on the MIPS R3000.

gcc options for architecture and code generation for MIPS

The following options for architecture and code generation can be used on all MIPS targets.

-g

The compiler debugging option ‘-g’ is essential to see interspersed high-level source statements, since without de-bugging information the assembler cannot tie most of the generated code to lines of the original source file.

-mcpu=r3000
-mcpu=cputype

Since most IDT boards are based on the MIPS R3000, the de-fault for this particular configuration is ‘-mcpu=r3000’.
In the general case, use this option on any MIPS platform to assume the defaults for the machine type cputype when scheduling instructions. The default cputype on other MIPS configurations is default, which picks the longest cycle times for any of the machines, in order that the code run at reasonable rates on any MIPS CPU. Other choices for cputype are r2000, r3000, r4000, r6000, r4400, r4600, r4650, r8000, and orion. While picking a specific cputype will schedule things appropriately for that particular chip, the compiler will not generate any code that does not meet level 1 of the MIPS ISA (Instruction Set Architecture) unless you use the -mips2, -mips3, or mips4 switch.

-mips1

Generate code that meets level 1 of the MIPS ISA.

-mips2

Generate code that meets level 2 of the MIPS ISA.

-mips3

Generate code that meets level 3 of the MIPS ISA.

-mips4

Generate code that meets level 4 of the MIPS ISA.

-meb

Generate big endian code.

-mel

Generate little endian code.

-mad

Generate multiply-add instructions, which are part of the MIPS 4650.

-m4650

Generate multiply-add instructions along with single-float code.

-mfp64

Select the 64-bit floating point register size.

-mfp32

Select the 32-bit floating point register size.

-mgp64

Select the 64-bit general purpose register size.

-mfp32

Select the 32-bit general purpose register size.

-mlong64

Make long integers 64 bits long, not the default of 32 bits long. This works only if you’re generating 64-bit code.

-G num

Put global and static items less than or equal to num bytes into the small ‘.data’ or ‘.bss’ sections instead of into the normal ‘.data’ and ‘.bss’ sections. This allows the assembler to emit one-word memory reference instructions based on the global pointer (gp or $28),instead of on the normal two words used. By default, num is 8. When you specify another value, gcc also passes the ‘-G num’ switch to the assembler and linker.

gcc options for floating point for MIPS

The following options select software or hardware floating point.

-msoft-float

Generate output containing library calls for floating point. The mips-idt-ecoff configuration of libgcc (an auxiliary library distributed with the compiler) include a collection of subroutines to implement these library calls.

In particular, this gcc configuration generates subroutine calls compatible with the US Software GOFAST R3000 floating point library, giving you the opportunity to use either the libgcc implementation or the US Software version. IDT includes the GOFAST library in their IDT C 5.0 package; you can also order libraries separately from IDT as the IDT kit of how to use gcc to link with the GOFAST library.

To use the ‘libgcc’ version, you need nothing special; gcc links with libgcc automatically after all other object files and libraries.

Because the calling convention for MIPS architectures depends on whether or not hardware floating-point is installed, ‘-msoft-float’ has one further effect: gcc looks for sub-routine libraries in a subdirectory, ‘soft-float’, for any library directory in your search path. (Note: This does not apply to directories specified using the ‘-l’ option.) With the GNUPro Toolkit, you can select the standard libraries as usual with the options, ‘-lc’ or ‘-lm’, because the soft-float versions are installed in the default library search paths.

Warning:
Treat ‘-msoft-float’ as an all or nothing proposition. If you compile any program’s module with ‘-msoft-float’, it’s safest to compile all modules of the program that way—and it’s essential to use this option when you link.

-mhard-float
Generate output containing floating point instructions, and use the corresponding MIPS calling convention. This is the default.

-msingle-float

Generate code for a target that only has support for single floating point values, such as the MIPS 4650.

Floating point subroutines

Two kinds of floating point subroutines are useful with gcc.

- Software implementations of the basic functions
Floating-point functionality for multiply, divide, add, subtract usage, used when there is no hardware floating-point support.
When you indicate that no hardware floating point is available (with the gcc option ‘-msoft-float’, gcc generates calls compatible with the US Software GOFAST library. If you do not have this library, you can still use software floating point; ‘libgcc’, the auxiliary library distributed with gcc, includes compatible—though slower—subroutines.
- General-purpose mathematical subroutines
GNUPro Toolkit includes an implementation of the standard C mathematical subroutine library. See Mathematical functions (math.h) in GNUPro Math Library in GNUPro Libraries.

Top|Contents|Index|Previous|Next